/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelos;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import org.jdesktop.observablecollections.ObservableCollections;
import org.jdesktop.observablecollections.ObservableList;

/**
 *
 * @Autor Gustavo Enrique Ruiz Cisneros <Desarrollador DSI/CGTI>
 * @Workspace DSI
 * @Fecha 3/10/2013
 */
public class Orden {

    public static final String PROP_ID = "id";
    public static final String PROP_IDORDEN = "idOrden";
    public static final String PROP_FECHAORDEN = "fechaOrden";
    public static final String PROP_IDCLIENTE = "idCliente";
    public static final String PROP_DETALLEORDEN = "detalleOrden";
    public static final String PROP_NOMCLIENTE = "nomCliente";
    public static final String PROP_DIRCLIENTE = "dirCliente";
    private Integer id;
    private Integer idOrden;
    private String fechaOrden;
    private Integer idCliente;
    private String nomCliente;
    private String dirCliente;
    private ObservableList<DetalleOrden> detalleOrden;

    public Orden() {
        id = 0;
        Date now = new Date();
        DateFormat df1 = DateFormat.getDateInstance(DateFormat.SHORT);      
        this.fechaOrden = String.valueOf(df1.format(now));
        detalleOrden = ObservableCollections.observableList(new LinkedList(new ArrayList<>())); 
    }

    public Orden(Integer id, Integer idOrden, String fechaOrden, Integer idCliente) {
        this.id = id;
        this.idOrden = idOrden;
        this.fechaOrden = fechaOrden;
        this.idCliente = idCliente;
    }

    public Orden(Integer id, Integer idOrden, String fechaOrden, Integer idCliente, String nomCliente, String dirCliente) {
        this.id = id;
        this.idOrden = idOrden;
        this.fechaOrden = fechaOrden;
        this.idCliente = idCliente;
        this.nomCliente = nomCliente;
        this.dirCliente = dirCliente;
    }
    

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Integer oldId = this.id;
        this.id = id;
        propertyChangeSupport.firePropertyChange(PROP_ID, oldId, id);
    }

    public Integer getIdOrden() {
        return idOrden;
    }

    public void setIdOrden(Integer idOrden) {
        Integer oldIdOrden = this.idOrden;
        this.idOrden = idOrden;
        propertyChangeSupport.firePropertyChange(PROP_IDORDEN, oldIdOrden, idOrden);
    }

    public String getFechaOrden() {
        return fechaOrden;
    }

    public void setFechaOrden(String fechaOrden) {
        String oldFechaOrden = this.fechaOrden;
        this.fechaOrden = fechaOrden;
        propertyChangeSupport.firePropertyChange(PROP_FECHAORDEN, oldFechaOrden, fechaOrden);
    }

    public Integer getIdCliente() {
        return idCliente;
    }

    public void setIdCliente(Integer idCliente) {
        Integer oldIdCliente = this.idCliente;
        this.idCliente = idCliente;
        propertyChangeSupport.firePropertyChange(PROP_IDCLIENTE, oldIdCliente, idCliente);
    }

    public String getNomCliente() {
        return nomCliente;
    }

    public void setNomCliente(String nomCliente) {
        String oldNomCliente = this.nomCliente;
        this.nomCliente = nomCliente;
        propertyChangeSupport.firePropertyChange(PROP_NOMCLIENTE, oldNomCliente, nomCliente);
    }

    public String getDirCliente() {
        return dirCliente;
    }

    public void setDirCliente(String dirCliente) {
        String oldDirCliente = this.dirCliente;
        this.dirCliente = dirCliente;
        propertyChangeSupport.firePropertyChange(PROP_DIRCLIENTE, oldDirCliente, dirCliente);
    }

    public ObservableList<DetalleOrden> getDetalleOrden() {
        return detalleOrden;
    }

    public void setDetalleOrden(ObservableList<DetalleOrden> detalleOrden) {
        ObservableList<DetalleOrden> oldDetalleOrden = this.detalleOrden;
        this.detalleOrden = detalleOrden;
        propertyChangeSupport.firePropertyChange(PROP_DETALLEORDEN, oldDetalleOrden, detalleOrden);
    }
    private transient final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.removePropertyChangeListener(listener);
    }
}
